﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Migrator.Framework;
using System.Data;

namespace Jobping.ShortUrls.Database
{
    [Migration(2)]
    public class Url_CaseSensitive : Migration
    {
        public override void Up()
        {
			string constraitName = (string)Database.ExecuteScalar(@"SELECT        CONSTRAINT_NAME
FROM            INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
WHERE        (TABLE_NAME = 'Url') AND (COLUMN_NAME = 'ShortUrl')"
				);

			Database.RemoveConstraint("Url", constraitName);

			Database.ExecuteNonQuery(@"
          ALTER TABLE Url 
ALTER COLUMN ShortUrl NVARCHAR(50) COLLATE Latin1_General_CS_AS NULL
	");

			Database.AddUniqueConstraint("ShortUrl_Unique", "Url", "ShortUrl");
        }

        public override void Down()
        {
           
        }

    }
}
